322B - Ciel and Flowers - CodeForces Solution


combinatorics math *1600

Please click on ads to support us..

Python Code:

r,g,b = map(int,input().split())

r2 = r%3
g2 = g%3
b2 = b%3
s  = r//3+g//3+b//3 + min(r2,g2,b2)
if ((r2+1)*(g2+1)*(b2+1) == 9) and (r*g*b != 0):
    s += 1
print(int(s))

C++ Code:

 #include<cstring>
    #define push_back pb
    #define push_front pf
    #define first F
    #define second S
    #include <bits/stdc++.h>
    #include <string>
    #define all(a) a.begin(), a.end()
    #define allr(a) a.rbegin(), a.rend()
    #include <iostream>
#include <cmath>
    typedef long long ll;
    typedef unsigned long long ull;
    using namespace std;
    const ll N = 1e5;
    const ll INF =1e10;
    const ll M= 1e9+7;
    map<char,ll>mp,bng;
    ll gcd(ll a,ll b){
        if(a==0 || b==0) return a+b;
        return gcd(b,a%b);
    }
//    ll pown(ll n, ll p){
//
//        if (p==0)
//            return 1;
//        ll tmp=(pown(n,p/2))%mod;
//        if(p%2==0){
//            ll pw=(tmp*tmp)%mod;
//            return pw;
//        }
//        else{
//            ll pw=(((n*tmp)%mod)*tmp)%mod;
//            return pw;
//        }
//    }
//    ll num[N];
//    set<ll>s;
//    vector<ll>primes;
//    void seive(){
//        num[2]=2;
//        for(int i = 3;i<N;i+=2){
//            num[i]=i;
//        }
//        for(int i = 3;i*i<N;i++){
//            if(num[i]==i){
//                for(int j = i*i;j<N;j+=i){
//                    num[j]=0;
//                }
//            }
//        }
//        for(int i = 2;i<N;i++){
//            if(num[i]==i){
//                primes.pb(i);
//            }
//        }
//    }
//    bool is_prime(ll n){
//        for(int i = 2;i*i<=n;i++){
//            if(n%i==0){
//                return false;
//            }
//        }
//        return true;
//    }
    ll lcm(ll a,ll b){
        ll g = gcd(a,b);
        ll p = a/g;
        ll q = b/g;
        return p*q*g;
    }

    int main()
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        ll a,b,c;
        cin>>a>>b>>c;
        ll mn = min({a,b,c});
        ll ans=0;
        if(a==b && c==b){
            cout<<a<<endl;
        }
        else{
            for(int i = 0;i<=min(3LL,mn);i++){
                ll tmans=i;
                ll p = a-i;
                ll q = b-i;
                ll r = c-i;
                tmans += (p/3)+(q/3)+(r/3);
                ans = max(ans,tmans);
            }
            cout<<ans<<endl;
        }






        return 0;
    }


Comments

Submit
0 Comments
More Questions

32B - Borze
1651B - Prove Him Wrong
381A - Sereja and Dima
41A - Translation
1559A - Mocha and Math
832A - Sasha and Sticks
292B - Network Topology
1339A - Filling Diamonds
910A - The Way to Home
617A - Elephant
48A - Rock-paper-scissors
294A - Shaass and Oskols
1213A - Chips Moving
490A - Team Olympiad
233A - Perfect Permutation
1360A - Minimal Square
467A - George and Accommodation
893C - Rumor
227B - Effective Approach
1534B - Histogram Ugliness
1611B - Team Composition Programmers and Mathematicians
110A - Nearly Lucky Number
1220B - Multiplication Table
1644A - Doors and Keys
1644B - Anti-Fibonacci Permutation
1610A - Anti Light's Cell Guessing
349B - Color the Fence
144A - Arrival of the General
1106A - Lunar New Year and Cross Counting
58A - Chat room